/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author msc
 */
@Entity
@Table(name = "TypeOfAccount")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TypeOfAccount.findAll", query = "SELECT t FROM TypeOfAccount t"),
    @NamedQuery(name = "TypeOfAccount.findByAccountTypeId", query = "SELECT t FROM TypeOfAccount t WHERE t.accountTypeId = :accountTypeId"),
    @NamedQuery(name = "TypeOfAccount.findByAccountTypeName", query = "SELECT t FROM TypeOfAccount t WHERE t.accountTypeName = :accountTypeName")})
public class TypeOfAccount implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "AccountTypeId")
    private Integer accountTypeId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 63)
    @Column(name = "AccountTypeName")
    private String accountTypeName;
    @OneToMany(mappedBy = "accountTypeId")
    private Collection<AccountInBank> accountInBankCollection;

    public TypeOfAccount() {
    }

    public TypeOfAccount(Integer accountTypeId) {
        this.accountTypeId = accountTypeId;
    }

    public TypeOfAccount(Integer accountTypeId, String accountTypeName) {
        this.accountTypeId = accountTypeId;
        this.accountTypeName = accountTypeName;
    }

    public Integer getAccountTypeId() {
        return accountTypeId;
    }

    public void setAccountTypeId(Integer accountTypeId) {
        this.accountTypeId = accountTypeId;
    }

    public String getAccountTypeName() {
        return accountTypeName;
    }

    public void setAccountTypeName(String accountTypeName) {
        this.accountTypeName = accountTypeName;
    }

    @XmlTransient
    public Collection<AccountInBank> getAccountInBankCollection() {
        return accountInBankCollection;
    }

    public void setAccountInBankCollection(Collection<AccountInBank> accountInBankCollection) {
        this.accountInBankCollection = accountInBankCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (accountTypeId != null ? accountTypeId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TypeOfAccount)) {
            return false;
        }
        TypeOfAccount other = (TypeOfAccount) object;
        if ((this.accountTypeId == null && other.accountTypeId != null) || (this.accountTypeId != null && !this.accountTypeId.equals(other.accountTypeId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.entities.TypeOfAccount[ accountTypeId=" + accountTypeId + " ]";
    }
    
}
